/// \file
#ifndef FILE_hdi_H
#define FILE_hdi_H

#include "globals.h"

typedef uint32_t blockid_t;

typedef struct HardDriveInterface_t_{
	uint16_t blockSize;
	uint32_t blockCount;
	byte_t *diskBlocksContinuous;
	byte_t **diskBlocksDiscontinuous;
}HardDriveInterface_t;


/// Creates a virtual disk.
/// 
/// Write the resutling struct to the address pointed by hdi.
fs_ret_t fs_newVirtualHDI(HardDriveInterface_t* hdi,uint32_t blockCount,uint16_t blockSize);

/// Delete the given virtual disk.
fs_ret_t fs_deleteVirtualHDI(HardDriveInterface_t* hdi);


/// Write the HDI to the hard drive to save it.
fs_ret_t fs_saveHDIToHardDrive(HardDriveInterface_t* hdi, const char* fileToSaveAs);

/// Creates an HDI from the pointed file.
fs_ret_t fs_loadHDIFromHardDrive(HardDriveInterface_t* hdi, const char* fileToLoad);


//// Read a block on the partition write it at dest (need to be already allocated).
fs_ret_t fs_getBlockFromHdi(HardDriveInterface_t* hdi,blockid_t id, byte_t * const dest);

/// Write from to the disk, in the indicated sector.
fs_ret_t fs_setBlockToHdi(HardDriveInterface_t* hdi,blockid_t id, const byte_t * from);

/// Print a block's content in sevral interpretations.
/// Be carfull with it as printing a block with a big block size
/// can be a bit long and unreadable.
fs_ret_t fs_d_print_block(HardDriveInterface_t* hdi,blockid_t blockId);

#endif // FILE_hdi_H
